#include "globalMessage.h"

emenyMessage::emenyMessage(string& str)
{
	flag = kind = angle = ax = ay = effect = addition = 0;
	time = 1;
	stringstream ss(str);
	string temp;
	ss >> temp;
	if (temp == "MoveTo")
	{
		flag = MOVETO;
		ss >> temp;
		if (temp == "Line")
		{
			kind = LINE;
			ss >> time >> angle;
		}else if (temp == "AccelerationX")
		{
			kind = ACCELERATIONX;
			ss >> time >> angle >> ax;
		}else if (temp == "AccelerationY")
		{
			kind = ACCELERATIONY;
			ss >> time >> angle >> ax;
		}else if (temp == "AccelerationXY")
		{
			kind = ACCELERATIONXY;
			ss >> time >> angle >> ax >> ay;
		}else if (temp == "Follow")
		{
			kind = FOLLOW;
			ss >> time;
		}else if (temp == "Player")
		{
			kind = PLAYER;
			ss >> time;
		}else if (temp == "Random")
		{
			kind = RANDOM;
			ss >> time;
		}else if (temp == "Round")
		{
			kind = ROUND;
			ss >> time >> ax >> ay >> angle >> addition;
		}
	}else
	if (temp == "wait")
	{
		flag = WAIT;
		ss >> time;
	}else
	if (temp == "Enter")
	{
		flag = ENTER;
		ss >> kind >> time;
	}else
	if (temp == "ShotBullet")
	{
		angle = INT_MAX;
		flag = SHOTBULLET;
		ss >> kind >> angle >> ax >> ay >> time >> temp;
		if (temp == "Round")
		{
			effect = ROUND;
		}else
			effect = NULL;
	}else if (temp == "END")
	{
		flag = END;
	}else if (temp == "Return")
	{
		flag = RETURNBACK;
		ss >> time;
	}else if (temp == "Repeat")
	{
		flag = REPEAT;
		ss >> time;
	}
}

bulletMessage::bulletMessage(string& str)
{
	flag = kind = time = angle = ax = ay = effect = 0;
	stringstream ss(str);
	string temp;
	ss >> temp;
	if (temp == "MoveTo")
	{
		flag = MOVETO;
		ss >> temp;
		if (temp == "Line")
		{
			kind = LINE;
			ss >> time >> angle;
		}else if (temp == "Follow")
		{
			kind = FOLLOW;
			ss >> time;
		}else if (temp == "Random")
		{
			kind = RANDOM;
			ss >> time;
		}else if (temp == "Round")
		{
			kind = ROUND;
			ss >> time;
		}else if (temp == "Player")
		{
			kind = PLAYER;
			ss >> time;
		}
	}else if (temp == "wait")
	{
		flag = WAIT;
		ss >> time;
	}else if (temp == "Enter")
	{
		flag = ENTER;
	}else if (temp == "ShotBullet")
	{
		flag = SHOTBULLET;
		ss >> kind >> time;
	}
}